<?php
namespace frontend\controllers;
use frontend\controllers\base\BaseController;

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017\11\20 0020
 * Time: 11:00
 *
 * 我的项目
 */
use Yii;
use common\models\ProjectLike;
use common\models\ProjectHighlights;
class MyProjectController extends BaseController {
    /**
     *我参与的项目
     * 资产被发起协同的和项目配置团队的
     */
    public function actionMyInvolvement(){
        //Yii::$app->user->identity->id; project_team  manager owner partner
        $use_id=3;
      // $use_id=Yii::$app->user->identity->id;



    }
    /**
     *我标记亮点的项目
     */
    public function actionMyHighLights(){
        $use_id=3;
       //$high= new ProjectHighlights();
        if(Yii::$app->request->isPost()){
            $keywords=Yii::$app->request->post('keywords');
            $data=ProjectHighlights::find()->with([
                'project'=>function($query) use ($keywords){$query->where(['title' =>$keywords ]);}
            ])->where('user_id=:user_id',[':user_id'=>$use_id]);
            return $this->render('showHighLights',['data'=>$data]);
        }
        $data=ProjectHighlights::find()->with('project')->where('user_id=:user_id',[':user_id'=>$use_id]);
        //$connection = \Yii::$app->db;
       // $sql1 = "SELECT pre_evaluation,due_diligence,other_team_notes,owner FROM package_initiation   WHERE  package_id = $package_id";
       // $Plandata1 = $connection->createCommand($sql1)->queryOne();
        //select 'project_id' from ProjectHighlights where user_id=$user_id
       // select * from Poject where title like '%keywords%' and id in(select 'project_id' from ProjectHighlights where user_id=$user_id)


        return $this->render('showHighLights',['data'=>$data]);
    }
    /**
     *我关注的项目
     */
    public function actionMyLike(){
        $use_id=3;
        if(Yii::$app->request->isPost()){
            $keywords=Yii::$app->request->post('keywords');
            $data=ProjectLike::find()->with([
                'project'=>function($query) use ($keywords){$query->where(['title' =>$keywords ]);}
            ])->where('user_id=:user_id',[':user_id'=>$use_id]);

        }
        $data=ProjectLike::find()->with('project')->where('user_id=:user_id',[':user_id'=> $use_id]);
    }
}